import java.util.*;
public class Solution {
    public int StrToInt(String str) {
        int flag=1;
        if(str.charAt(0)=='-'){
            flag=-1;
        }
        long  sum=0;
        for(int i=0;i<str.length();i++){
            if(str.charAt(0)=='-'||str.charAt(0)=='+'){
                i=i+1;
            }else{
                System.out.print(0);
            }
            if(str.charAt(i)>='0'&&str.charAt(i)<='9'){
                int val=(str.charAt(i)-'0');
                sum=sum+val;
                if(i<str.length()-1) {
                    sum = sum * 10;
                }
            }else{
                return 0;
            }
        }
        sum=sum*flag;
        System.out.println(sum);
        return (int)sum;
    }
   //JZ85 连续子数组的最大和(二)
    public int[] FindGreatestSumOfSubArray (int[] array) {
        if (array.length == 0) {
            return new int [0];
        }
        int left = 0, right = 0; //遍历区间
        int resl = 0, resr = 0; //滑动区间
        int [] arr = new int [array.length];
        arr[0] = array[0];
        int max = array[0];
        for (int i = 1; i < array.length; i++) {
            right++;
            arr[i] = Math.max(arr[i - 1] + array[i], array[i]);
            if (arr[i - 1] + array[i] < array[i]) {
                left = right;
            }
            if (arr[i] > max || arr[i] == max && (right - left + 1) > (resr - resl + 1)) {
                max = arr[i];
                resl = left;
                resr = right;
            }
        }
        int [] dp=new int[resr-resl+1];
        for(int i=0;i<dp.length;i++){
            dp[i]=array[resl];
               resl++;
        }
        return dp;
    }
}

